﻿using System;
using System.Configuration;
using System.IO;
using System.Web.Mvc;
using System.Web.Routing;
using Rhino.Commons.HttpModules;

namespace WebUI
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : UnitOfWorkApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{*alljs}", new { allaspx = @".*\.js(/.*)?" });
            routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
            routes.IgnoreRoute("{*Content}", new { content = @"(.*/)?Content(/.*)?" });

            routes.MapRoute(
                "Default",                                                 // Route name
                "{controller}/{action}/{id}",                              // URL with parameters
                new { controller = "Home", action = "About", id = "" }  // Parameter defaults
            );

        }

        public override void Application_Start(object sender, EventArgs e)
        {
            base.Application_Start(sender, e); 
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory());
            RegisterRoutes(RouteTable.Routes);
        }
    }
}